#**************************************************************************
#*
#* File       : LINK.MK
#* Function   :
#* Application:
#* Programmer : ATL Group
#* Date Coded : 
#* Warnings   :
#*
#* ------------------------------------------------------------------------
#*
#   This build file requires certain environmental variables
#   to have been set, preferably in your autoexec.bat file:
#      SDS  - should be set to the directory containing the SDS files (e.g. c:\SDS71)
#      VFSDK - should be set to the directory containing the SDK tools (e.g. c:\VFSDK)
#      VFDEV - should be set to the directory containing the Foundation library (e.g. c:\VFDEV)
#
#* Copyright (C) 1997, VeriFone Inc. All rights reserved.
#*
#* No part of this software may be used, stored, compiled, reproduced,
#* modified, transcribed, translated, transmitted, or transferred, in
#* any form or by any means whether electronic, mechanical, magnetic,
#* optical, or otherwise, without the express prior written permission
#* of VeriFone, Inc.
#*
#**************************************************************************

# Library Paths
SDS_TOOLS=C:\sds70\cmd
SDKRoot  = $(VFSDK)\$(SDK_VER)
ACTRoot  = $(ACT2000)\$(ACT_VER)
SERFRoot = $(SERF)\$(SERF_VER)
VMACResDir = $(SRC_ROOT)\VMAC

SDKLibraries = $(SDKRoot)\lib
ACTLibraries = $(ACTRoot)\lib


AppModulesLibs =               \
	$(LIB_DIR)\main.a			   \
	$(LIB_DIR)\accum.a			   \
	$(LIB_DIR)\batch.a			   \
	$(LIB_DIR)\card.a			   \
	$(LIB_DIR)\comm.a			   \
	$(LIB_DIR)\common.a 		   \
        $(LIB_DIR)\control.a                \
        $(LIB_DIR)\config.a                \
        $(LIB_DIR)\ISODump.a	   \
	$(LIB_DIR)\Merch.a			   \
	$(LIB_DIR)\Msg.a			   \
	$(LIB_DIR)\pfr.a			   \
	$(LIB_DIR)\PINPad.a 		   \
	$(LIB_DIR)\PIP.a			   \
	$(LIB_DIR)\Print.a			   \
	$(LIB_DIR)\Protocol.a		   \
	$(LIB_DIR)\rcptcmpt.a		   \
	$(LIB_DIR)\retry.a			   \
	$(LIB_DIR)\Rs232Com.a		   \
	$(LIB_DIR)\seccode.a		   \
	$(LIB_DIR)\shift.a			   \
	$(LIB_DIR)\stats.a			   \
	$(LIB_DIR)\UI.a 			   \
	$(LIB_DIR)\Tran.a			   \
	$(LIB_DIR)\Utils.a			   \
	$(LIB_DIR)\VID.a			   \
	$(LIB_DIR)\Ztconfig.a		   \
	$(LIB_DIR)\Ztexpress.a		   \
	$(LIB_DIR)\CommsH.a 		   \
	$(LIB_DIR)\SPUCL.a			   \
##	$(LIB_DIR)\ucl.a  				\
        $(LIB_DIR)\EMVSrc.a   				\
        $(LIB_DIR)\cpacsrc.a                         \
##        $(LIB_DIR)\axapsrc.a                         \
##        $(LIB_DIR)\jcbisrc.a                         \
##        $(LIB_DIR)\dincsrc.a                         \
##        $(LIB_DIR)\bochsrc.a                         \
        $(LIB_DIR)\cashsrc.a                         \
        $(LIB_DIR)\cabksrc.a                         \
        $(LIB_DIR)\eppsrc.a                         \
	$(LIB_DIR)\imam.a                         \
        $(LIB_DIR)\$(SP_PROJ).a   \
	$(LIB_DIR)\$(SP_PROJ)Src.a   \
	$(LIB_DIR)\project.a

FoundationLibs =  \
$(ACTRoot)\OutPut\SDS\Files\ShLib1\Debug\ACT.slk    \
##$(ACTRoot)\Output\Files\Static\Debug\Act2000.a \
$(SERFRoot)\lib\serf.a \
$(SERFRoot)\lib\serfextra.a \
$(SERFRoot)\lib\txoserf.a \
$(SDKRoot)\lib\libsys.a                         \
$(SDKRoot)\lib\libvoy.a                         \
$(SDKRoot)\lib\AESLib.a				\
$(VVXEMVAP)\$(XEMV_VER)\Output\SDS\Files\Static\Debug\VFRSA_09.O    \
$(VVXEMVAP)\$(XEMV_VER)\Output\SDS\Files\Static\Debug\emv.a              \
$(VVXEMVAP)\$(XEMV_VER)\Output\SDS\Files\Static\Debug\sha.a                      \
$(VVXEMVAP)\$(XEMV_VER)\Output\SDS\Files\Static\Debug\vxemvap.a                   \
$(VVXEMVAP)\$(XEMV_VER)\Output\SDS\Files\Static\Debug\emvap_config.a   \
$(CARDSLOT)\$(CLS_VER)\Output\SDS\Files\Static\Debug\cardslot.a        \
$(TCPIP)\$(TCPIP_VER)\OutPut\SDS\Files\Static\Debug\vtcpip.a	\
$(UCL)\$(UCL_VER)\OutPut\SDS\Files\Static\Debug\ucl.a 

# Compiler Options
Includes = -I $(SDS_INCLUDES) -I $(ACT_INCLUDES) -I $(SP2_INCLUDES)  -I $(CLS_INCLUDES) -I $(VVXEMV_INCLUDES) -I $(UCLIncludes) -I $(TCPIPIncludes)
COptions = -D__K2__ -D_VSC -D_DEBUG -f -s int=2 -s sizeof=2 -O d -r a4 -r a5 -o $(@)
linkOptions = -X -y -w -f$(SDKRoot)\config\link.spc -d $(SDKRoot)\lib\_start.o

pseudoOut : $(SPFILES)\sp2000.out
#pseudoOut : $(SPFILES)\sp2000.out
  @Echo Running OutHdr and Signing...
    @$(VFSDK)\$(SDK_VER)\outhdr -t -v 1.0 -s 60000 -h 90000 -lact.lib=f:/act.lib $(SPFILES)\sp2000.out
## imam    @outhdr -t -v 1.0 -s 60000 -h 90000 -lact.lib=f:/act.lib $(SPFILES)\sp2000.out
##  @outhdr -t -v 1.0 -s 10000 -h 40000 -lact.lib=f:/act.lib $(SPFILES)\sp2000.out
##  @outhdr -t -v 1.0 -s 60000 -h 90000 $(SPFILES)\sp2000.out

  \SOFTPAY\VER30\TOOLS\FILESIGN -c $(SDKRoot)\CONFIG\K2SIGN.CRT -k $(SDKRoot)\CONFIG\K2SIGN.KEY -f $(SPFILES)\sp2000.OUT -s $(SPFILES)\sp2000.p7s
  \SOFTPAY\VER30\TOOLS\FILESIGN -c $(SDKRoot)\CONFIG\K2SIGN.CRT -k $(SDKRoot)\CONFIG\K2SIGN.KEY -f $(SPFILES)\dbmon.OUT -s $(SPFILES)\dbmon.p7s
 \SOFTPAY\VER30\TOOLS\FILESIGN -c $(SDKRoot)\CONFIG\K2SIGN.CRT -k $(SDKRoot)\CONFIG\K2SIGN.KEY -f $(SPFILES)\act.lib -s $(SPFILES)\act.p7s -L
  \SOFTPAY\VER30\TOOLS\FILESIGN -c $(SDKRoot)\CONFIG\K2SIGN.CRT -k $(SDKRoot)\CONFIG\K2SIGN.KEY -f $(SPFILES)\sp2000.OUT -s $(SPFILES)\sp2flash.p7s -L
  
$(SPFILES)\sp2000.out : $(DBG_DIR)\sp2000.odb
  @Echo Running Down...
  @$(SDS_TOOLS)\down -F$(SDKRoot)\config\down.opt $(DBG_DIR)\sp2000.odb -o $(@)

$(DBG_DIR)\sp2000.odb : $(AppModulesLibs) $(FoundationLibs) 
  @Echo Running Linker...
  @echo $(AppModulesLib)
  @$(SDS_TOOLS)\linker $(linkOptions) $(FoundationLibs) $(AppModulesLibs) -o $(@)
